package com.jn.zhinongbao.adapter.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.supportingagriculturaltreasures.PublishProductActivity;
import com.example.supportingagriculturaltreasures.PublishPurchaseActivity;
import com.example.supportingagriculturaltreasures.R;

public class MerchantPublishFragment extends Fragment {

    private LinearLayout llPublishProduct, llPublishPurchase;

    public static MerchantPublishFragment newInstance() {
        return new MerchantPublishFragment();
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_merchant_publish, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        
        initViews(view);
        setupClickListeners();
    }

    private void initViews(View view) {
        llPublishProduct = view.findViewById(R.id.ll_publish_product);
        llPublishPurchase = view.findViewById(R.id.ll_publish_purchase);
    }

    private void setupClickListeners() {
        llPublishProduct.setOnClickListener(v -> {
            Intent intent = new Intent(getActivity(), PublishProductActivity.class);
            startActivity(intent);
        });

        llPublishPurchase.setOnClickListener(v -> {
            Intent intent = new Intent(getActivity(), PublishPurchaseActivity.class);
            startActivity(intent);
        });
    }
} 